#       Makefile
#       
#       Copyright 2011 Philipp Müller <pmedia@xi-intersection.net>
#       
#       This program is free software; you can redistribute it and/or modify
#       it under the terms of the GNU General Public License as published by
#       the Free Software Foundation; either version 2 of the License, or
#       (at your option) any later version.
#       
#       This program is distributed in the hope that it will be useful,
#       but WITHOUT ANY WARRANTY; without even the implied warranty of
#       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#       GNU General Public License for more details.
#       
#       You should have received a copy of the GNU General Public License
#       along with this program; if not, write to the Free Software
#       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
#       MA 02110-1301, USA.

CC      := g++
LD      := g++
LDFLAGS := -lGL -lGLU `sdl-config --libs`
CCFLAGS := `sdl-config --cflags` -Wall -Wstrict-prototypes -ggdb
SRCLIST := $(wildcard *.cpp)
HDRLIST := $(wildcard include/*.hpp)
OBJLIST := $(patsubst %.c,%.o,$(SRCLIST))
BIN     := ../../bin/xivr-server-sc

all: linecount $(BIN)

test: linecount $(BIN)
	@$(BIN)

%.o: %.cpp include/%.hpp
	$(CC) $(CCFLAGS) -c $<

%.o: %.cpp
	$(CC) $(CCFLAGS) -c $<

$(BIN): $(OBJLIST)
	$(LD) -o $(BIN) $(LDFLAGS)  $(OBJLIST)

.PHONY: clean test new linecount

linecount:
	@cat $(SRCLIST) $(HDRLIST) | wc | sed 's/ \+/ /g' | awk '{print "\nXi VR\n=============================\n\n" $$1 " lines of code yet\n" $$2 " Words\n" $$3 " Bytes\n"}'
	
new:
	make clean
	make

clean:
	clear
	rm -f $(OBJLIST) $(BIN)
